package com.bkfm.framework.core.api.service;

import java.io.File;
import java.util.List;
import java.util.Map;

import org.yak.core.service.IBaseService;
import org.yak.core.store.PageParam;
import org.yak.core.web.ResultSet;

import com.bkfm.framework.core.entity.BkfmDataRecord;
import com.bkfm.framework.core.entity.BkfmFiles;
import com.bkfm.framework.core.entity.BkfmFilter;
import com.bkfm.framework.core.entity.BkfmTableMetaData;
import com.bkfm.framework.core.entity.BkfmTreeModel;
import com.bkfm.framework.core.utils.ExecuteCall;
import com.bkfm.framework.core.utils.QueryCall;
import com.bkfm.framework.utils.BkfmExpImpColumn;
import com.github.pagehelper.PageInfo;

public interface IBkfmTableMetaServer extends IBaseService<BkfmTableMetaData>{

	/**
	 * 查询所有业务模型数据
	 * @return
	 * @throws Exception
	 */
	public List<BkfmTableMetaData> queryTableMetaAllList()throws Exception;
	
	/**
	 * 查询业务数据表结构模型
	 * @param tableMetaData
	 * @return
	 * @throws Exception
	 */
	public List<BkfmTableMetaData> queryTableMetaColumn(BkfmFilter bkfmFilter)throws Exception;
	
	/**
	 * 查询业务数据记录
	 * @param tableMetaData
	 * @param pageBounds
	 * @return
	 * @throws Exception
	 */
	public PageInfo<Map<String,Object>> queryPageInfoMap(BkfmFilter bkfmFilter,PageParam pageBounds)throws Exception;
	
	/**
	 * 查询业务数据记录
	 * @param tableMetaData
	 * @param pageBounds
	 * @return
	 * @throws Exception
	 */
	public PageInfo<ResultSet> queryPageInfoResultSet(BkfmFilter bkfmFilter,PageParam pageBounds)throws Exception;
	
	/**
	 * 查询单调记录
	 * @param bkfmFilter
	 * @return
	 * @throws Exception
	 */
	public Map<String,Object> queryTableModelMetaData(BkfmFilter bkfmFilter)throws Exception;
	
	/**
	 * 查询结果集返回ResultSet对象
	 * @param bkfmFilter
	 * @return
	 * @throws Exception
	 */
	public ResultSet queryTableModelMetaResultSet(BkfmFilter bkfmFilter)throws Exception;
	
	/**
	 * 查询结果集返回ResultSet对象
	 * @param bkfmFilter
	 * @return
	 * @throws Exception
	 */
	public List<ResultSet> queryTableModelMetaResultSetList(BkfmFilter bkfmFilter)throws Exception;
	
	/**
	 * 保存或者修改数据
	 * @param dataRecord
	 * @throws Exception
	 */
	public void saveModelMetaData(List<BkfmDataRecord> dataRecord)throws Exception;
	
	/**
	 * 新增
	 * @param record
	 * @throws Exception
	 */
	public void addModelMetaData(BkfmDataRecord record) throws Exception;
	
	/**
	 * 修改
	 * @param record
	 * @throws Exception
	 */
	public void modifyModelMetaData(BkfmDataRecord record) throws Exception;
	
	/**
	 * 删除
	 * @param record
	 * @throws Exception
	 */
	public void deleteModelMetaData(List<BkfmFilter> bkfmFilterList) throws Exception;
	
	/**
	 * 查询下啦选项
	 * @param bkfmFilter
	 * @return
	 * @throws Exception
	 */
	public List<Map<String,Object>> queryComboBoxMeta(BkfmFilter bkfmFilter) throws Exception;
	
	/**
	 * 查询树结构
	 * @param param
	 * @return
	 * @throws Exception
	 */
	public List<Map<String,Object>> queryTreeMeta(BkfmTreeModel param)throws Exception;
	
	
	/**
	 * 根据输入的sql查询结果集
	 * @param sql sql语句
	 * @param queryCall 回调方法
	 * @throws Exception
	 */
	public List<ResultSet> queryResultBySql(String sql,QueryCall queryCall) throws Exception;
	
	/**
	 * 执行单调sql语句
	 * @param sql
	 * @param executeCall
	 * @return
	 * @throws Exception
	 */
	public int executeSql(String sql,ExecuteCall executeCall)throws Exception;
	
	/**
	 * 批量执行sql
	 * @param sql
	 * @param executeCall
	 * @throws Exception
	 */
	public void executeBatchSql(List<String> sql,ExecuteCall executeCall)throws Exception;
	
	/**
	 * 检查记录数
	 * @param bkfmFilter
	 * @return
	 * @throws Exception
	 */
	public int checkNumber(BkfmFilter bkfmFilter)throws Exception;
	
	/**
	 * 导出excel文件
	 * @param bkfmFilter
	 * @param expColumnList
	 * @throws Exception
	 */
	public String exportData(BkfmFilter bkfmFilter,List<String> expColumnList)throws Exception;
	
	/**
	 * 导入数据
	 * @param bkfmFilter
	 * @param impColumnList
	 * @param importFile
	 * @return
	 * @throws Exception
	 */
	public void importData(BkfmFilter bkfmFilter,List<BkfmExpImpColumn> impColumnList,File importFile)throws Exception;
	
	/**
	 * 保存上传的附件
	 * @param fileList
	 * @throws Exception
	 */
	public void uploadFile(List<BkfmFiles> bkfmFilesList)throws Exception;
	
}
